import requests

url = 'https://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData?page=1&num=40&sort=symbol&asc=1&node=hs_bjs&symbol=&_s_r_a=init'

res = requests.get(url)

data = res.json()

format_title = "{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t"
print(format_title.format('名称', '最新价', '涨跌额', '涨跌幅', '买入', '卖出', '昨收', '今开', '最高', '最低', '成交量/手', '成交额/万'))

for i in data:
    format_data = "{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t{:^5}\t"
    print(format_data.format(i["name"], i["trade"], i['pricechange'], i['changepercent'], i['buy'], i['sell'], i['settlement'], i['open'], i['high'], i['low'], i[ 'volume'] ,i['amount']))

